import 'package:flutter/material.dart';

import 'package:get/get.dart';

import '../controllers/widget_list_controller.dart';

class WidgetListView extends GetView<WidgetListController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Widget案例'),
        centerTitle: true,
      ),
      body: Container(
        child: Obx(
          () => ListView.builder(
            itemBuilder: (context, index) {
              var w = controller.widgets[index];
              return Container(
                height: 60,
                child: TextButton(
                  child: Text(w.title),
                  onPressed: () => {
                    Get.toNamed(w.route)
                  },
                ),
              );
            },
            itemCount: controller.widgets.length,
          ),
        ),
        height: double.infinity,
      ),
    );
  }
}
